<%--
    Document   : listRecentPosts
    Created on : Apr 27, 2014, 4:47:58 PM
    Author     : Anton Strack
--%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="csd" tagdir="/WEB-INF/tags" %>
<%@tag description="Lists the recent posts passed on the recentPosts attribute " pageEncoding="UTF-8"%>
<%@attribute name="recentPosts" type="java.util.List<csdwa.Post>"%>
<%@attribute name="emptyMessage" required="true"%>
<c:choose>
    <c:when test="${recentPosts != null && recentPosts.size() > 0}">
        <c:forEach items="${recentPosts}" var="recentPost" >
            <%--  might apply user history visual indicators to recent posts. not sure yet. <csd:userPostHistory postItemBean="${recentPost}"></csd:userPostHistory> ${postHistoryStateClass} --%>
            <li class="list-group-item"><a href="${req.contextPath}?action=view&resource=${fn:toLowerCase(recentPost.getDerivedValue('ResourceTypeName'))}&id=${recentPost.id}">${recentPost.name}</a><br />
                <c:choose>
                    <c:when test="${recentPost.updatedDate > recentPost.createdDate}">
                        Updated: <csd:displayTimestamp timestamp="${recentPost.updatedDate}"></csd:displayTimestamp>
                    </c:when>
                    <c:otherwise>
                        Created: <csd:displayTimestamp timestamp="${recentPost.createdDate}"></csd:displayTimestamp>
                    </c:otherwise>
                </c:choose>
            </li>
        </c:forEach>
    </c:when>
    <c:otherwise>
        <li class="list-group-item">${emptyMessage}</li>
        </c:otherwise>
    </c:choose>

